package com.fafa.File;

import org.junit.Test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FileReader_Write {
    public static void main(String[] args) {

    }

    @Test
    public void readFile_()
    {
        File file = new File("E:\\1.txt");
        FileReader fileReader = null;
        char [] buf = new char[1024];
        try {
            fileReader = new FileReader(file);
            int len = 0;
            while((len = fileReader.read(buf)) != -1)
            {
                System.out.println(new String(buf, 0, len));
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                fileReader.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
